
set scheme s1mono

******************************
* Generate treatment variable*
******************************

*destring text from survey experiment
gen tekst1= substr( b_14,1,2)
tab tekst1
sort tekst1
drop if tekst1=="<p"
gen tekst2= substr( b_15,1,2)
tab tekst2

*generate three groups: deterioration, stability and improvement
destring tekst1 tekst2, replace
gen forskel=tekst1-tekst2
tab forskel

*generate treatment variable
gen treatment=forskel
replace treatment=1 if forskel==-25
replace treatment=2 if forskel==0
replace treatment=3 if forskel==25

label define Treat 1 "Deterioration" 2 "Stability" 3 "Improvement"
label values treatment Treat

*generate variable measuring current level of performance
gen current=.
replace current=1 if tekst1==25
replace current=2 if tekst1==50
replace current=3 if tekst1==75

*generate initial level of performanfe
gen initial=.
replace initial=1 if tekst2==25
replace initial=2 if tekst2==50
replace initial=3 if tekst2==75

**************************
*Generate other variables*
*************************

*set do not know to missing
foreach var of varlist s_335-s_340 {
replace `var'=. if `var'==6
}

*drop missing values for performance information use items
foreach var of varlist s_335-s_338 {
drop if `var'==.
}

*Factor analysis for index measuring performance information use (4 items)
factor s_335-s_338, pcf
predict piu
alpha s_335-s_338



*Factor analysis for index measuring performance information use (5 items)
factor s_335-s_339, pcf
predict fiveitem
alpha s_335-s_339

*gen trust variable
gen trust=s_340

**********************************
* Regressions models for table A2*
**********************************

reg piu i.current

reg piu ib(2).treatment

*******************
*Grapfs (figure 2)*
*******************
preserve
collapse (mean) mean= piu (semean) se=piu, by(current)
generate upper=mean+1.96*se
generate lower=mean-1.96*se
generate upper1=mean+1.4*se
generate lower1=mean-1.4*se
graph twoway || rcap upper lower current, lstyle(p1) ||scatter mean current, mstyle(p1)  || , legend(off) xtitle("") xlabel(1 "Low" 2 "Average" 3 "High", noticks)  xsize(3) ysize(3) xscale(range(0.5 3.5)) ytitle("")
graph export curret.png, replace
restore

preserve
collapse (mean) mean= piu (semean) se=piu, by(treatment)
generate upper=mean+1.96*se
generate lower=mean-1.96*se
generate upper1=mean+1.4*se
generate lower1=mean-1.4*se
graph twoway || rcap upper lower treatment, lstyle(p1) ||scatter mean treatment, mstyle(p1)  || , legend(off) xtitle("") xlabel(1 "Deterioration" 2 "Stability" 3 "Improvement", noticks) xsize(3) ysize(3) xscale(range(0.5 3.5)) ytitle("")
graph export treatment.png, replace
restore



**********************************************************
* Regressions given initial level of performance (table 2)*
**********************************************************
ttest piu if initial==1, by(treatment)

ttest piu if initial==2 & treatment>1, by(treatment)

ttest piu if initial==2 & treatment<3, by(treatment)

ttest piu if initial==3, by(treatment)

**************************************************
*Regression models for individual items (Table 3)*
**************************************************
foreach var of varlist s_335-s_338 {
reg `var' ib(2).treatment
}


**********
*Appendix*
**********

********
*TRUST*
*******
*Figure A1

preserve
collapse (mean) mean= trust (semean) se=trust, by(treatment)
generate upper=mean+1.96*se
generate lower=mean-1.96*se
generate upper1=mean+1.4*se
generate lower1=mean-1.4*se
graph twoway || rcap upper lower treatment, lstyle(p1) ||scatter mean treatment, mstyle(p1)  || , legend(off) xtitle("") xlabel(1 "Deterioration" 2 "Stability" 3 "Improvement", noticks) xsize(3) ysize(3) xscale(range(0.5 3.5)) ytitle("")
graph export trust.png, replace
restore

*regression
reg trust i.treatment

************
*Figure A3*
************

gen allgroup=.

replace allgroup=3 if treatment==1 & initial==2
replace allgroup=6 if treatment==1 & initial==3
replace allgroup=1 if treatment==2 & initial==1
replace allgroup=4 if treatment==2 & initial==2
replace allgroup=7 if treatment==2 & initial==3
replace allgroup=2 if treatment==3 & initial==1
replace allgroup=5 if treatment==3 & initial==2


preserve
collapse (mean) mean= piu (semean) se=piu, by(allgroup)
generate upper=mean+1.96*se
generate lower=mean-1.96*se
graph twoway || rcap upper lower allgroup, lstyle(p1) ||scatter mean allgroup, mstyle(p1) ||, legend(off) xtitle("Allgroup") xlabel(1 "L-S" 2 "L-I" 3 "A-D" 4 "A-S" 5 "A-I" 6 "H-D" 7 "H-S") ytitle("Mean")
graph export allgroup.png, replace
restore

foreach i of num 1/7 {
reg piu ib(`i').allgroup
}


****************************
*five item index (figure A4)
****************************
reg fiveitem ib(2).current
reg fiveitem ib(2).treatment

*graphs
preserve
collapse (mean) mean= fiveitem (semean) se=fiveitem, by(current)
generate upper=mean+1.96*se
generate lower=mean-1.96*se
generate upper1=mean+1.4*se
generate lower1=mean-1.4*se
graph twoway || rcap upper lower current, lstyle(p1) ||scatter mean current, mstyle(p1)  || , legend(off) xtitle("") xlabel(1 "Low" 2 "Average" 3 "High", noticks)  xsize(3) ysize(3) xscale(range(0.5 3.5)) ytitle("")
graph export fiveitem.png, replace
restore

preserve
collapse (mean) mean= fiveitem (semean) se=piu, by(treatment)
generate upper=mean+1.96*se
generate lower=mean-1.96*se
generate upper1=mean+1.4*se
generate lower1=mean-1.4*se
graph twoway || rcap upper lower treatment, lstyle(p1) ||scatter mean treatment, mstyle(p1)  || , legend(off) xtitle("") xlabel(1 "Deterioration" 2 "Stability" 3 "Improvement", noticks) xsize(3) ysize(3) xscale(range(0.5 3.5)) ytitle("")
graph export fiveitem2.png, replace
restore
